package com.whw.springboot.bcucb.controller;

import com.whw.springboot.bcucb.entity.Comment;
import com.whw.springboot.bcucb.entity.Message;
import com.whw.springboot.bcucb.entity.Star;
import com.whw.springboot.bcucb.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "评价记录")
@RestController
@RequestMapping("/api/Comment")
public class CommentController {
    @Resource
    private CommentService commentService;

    /**
     * 增加评价记录
     */
    @ApiOperation(value = "增加评价记录")
    @PostMapping(value = "/")
    public Message<?> insertCaselevel(Comment comment){
        return commentService.insertSelective(comment);
    }

    /**
     * 删除评价记录
     */
    @ApiOperation(value = "删除评价记录")
    @DeleteMapping(value = "/")
    public Message<?> deleteByCaselevelId(int commenId){
        return commentService.deleteByPrimaryKey(commenId);
    }

    /**
     * 修改评价记录
     */
    @ApiOperation(value = "修改评价记录")
    @PutMapping(value = "/")
    public Message<?> updateByCaselevelId(Comment comment){
        return commentService.updateByPrimaryKeySelective(comment);
    }

    /**
     * 查看某一个评价记录
     */
    @ApiOperation(value = "查看某一个评价记录")
    @GetMapping(value = "/one")
    public Message<Comment> selectByCaselevelId(int commenId){
        return commentService.selectByPrimaryKey(commenId);
    }

    /**
     * 查看所有个评价记录
     */
    @ApiOperation(value = "查看所有个评价记录")
    @GetMapping(value = "/all")
    public Message<List<Comment>> selectByCaselevelId(){
        return commentService.selectAll();
    }
}
